package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.dto.OrderDto;
import com.itheima.service.OrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class orderController {
    @Autowired
    private OrderService orderService;

    /**
     * 分页查找
     * @param queryPageBean
     * @return
     */
    @PostMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return orderService.findPage(queryPageBean);
    }

    @PostMapping("/update")
    public Result update(@RequestBody OrderDto orderDto){
        boolean temp = orderService.updata(orderDto);
        return new Result(temp,temp? MessageConstant.EDIT_ORDER_STATUS_SUCCESS:MessageConstant.EDIT_ORDER_STATUS_FAIL);
    }
}
